package com.ruoyi.app.controller.shop.service.impl;

import com.ruoyi.app.controller.shop.mapper.IShopAppletMapper;
import com.ruoyi.app.controller.shop.service.IShopAppletService;
import com.ruoyi.common.entity.DO.shop.ShopAppletDO;
import com.ruoyi.common.exception.BusinessException;
import org.springframework.stereotype.Service;
import tk.mybatis.mapper.entity.Example;

import javax.annotation.Resource;

@Service
public class ShopAppletServiceImpl implements IShopAppletService {

    @Resource
    private IShopAppletMapper shopAppletMapper;

    @Override
    public ShopAppletDO getDetailByShopId(Long shopId) {
        try{
            Example example = new Example(ShopAppletDO.class);
            example.createCriteria().andEqualTo("shopId", shopId)
                    .andEqualTo("isDelete", 0)
                    .andEqualTo("isEnable", 1);
            return shopAppletMapper.selectByExample(example).get(0);
        }catch (Exception e){
            return null;
        }
    }

    @Override
    public ShopAppletDO getDetailByAppId(String appId) {
        try{
            Example example = new Example(ShopAppletDO.class);
            example.createCriteria().andEqualTo("appletAppId", appId);
            return shopAppletMapper.selectByExample(example).get(0);
        }catch (Exception e){
            return null;
        }

    }
}
